package com.teach.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import com.teach.dto.ProductSearch;
import com.teach.dto.ShopProductSearch;
import com.teach.entity.Product;

public interface ProductMapper {
    int deleteByPrimaryKey(Long productId);

    int insert(Product record);

    int insertSelective(Product record);

    Product selectByPrimaryKey(Long productId);
    
    @Select("select * from product where PRODUCT_ID=#{productId}")
    List<Product> selectByID(@Param("productId")Long productId);

    int updateByPrimaryKeySelective(Product record);

    int updateByPrimaryKeyWithBLOBs(Product record);

    int updateByPrimaryKey(Product record);
    
    @Select("select * from product where PRODUCT_ID=#{productId}")
    Product selectB(@Param("productId")Long productId);
    
    @Select("select * from product")
    List<Product> selectAll();
    
    List<Product> select(ProductSearch search);
    
	/* @Select("select * from product") */
    List<Product> selects(ShopProductSearch search);
    @Select("SELECT * from product where PRODUCT_OUT=1 and PRODUCT_NAME LIKE concat('%',#{productName},'%') ORDER BY PRODUCT_SALES desc LIMIT 3")
    List<Product>selectByName(@Param("mohuName") String mohuName);
    
    @Select("SELECT * FROM product where PRODUCT_CLASS_ID=(\r\n" + 
    		"select PRODUCT_CLASS_ID from product where PRODUCT_ID=#{productId}\r\n" + 
    		") LIMIT 3")
    List<Product>selectByProductID(@Param("productId")Long productId);
}